<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/layui/layui.css}"  media="all" />
    <link rel="stylesheet" th:href="@{/css/text.css}"  />
    <script type="text/javascript" th:src="@{/js/jquery-3.2.1.js}"></script>
    <script th:src="@{/layui/layui.all.js}" charset="utf-8"></script>

    <script>
        function del(n, id) {
            layer.confirm('确认删除该公告信息', function (index) {
            $.ajax({
                type: "DELETE",
                url: "/dor/text/" + id,
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) { // Play with response returned in JSON format
                    window.location.reload(true);
                    return true;
                },
                error: function (msg) {
                    return false;
                }
            });
        })
        }
    </script>

</head>
<body bgcolor="">
<!--轮播图片-->
<div class="layui-carousel" id="test1">
    <div carousel-item="">
        <div><img src="image/lun.jpg" width="100%" height="100%"/></div>
        <div><img src="image/lun2.jpg" width="100%" height="100%"/></div>
        <div><img src="image/13.jpg" width="100%" height="120%"/></div>
    </div>
</div>
<script>
    layui.use('carousel', function () {
        var carousel = layui.carousel;
        //建造实例
        carousel.render({
            elem: '#test1'
            , width: '100%' //设置容器宽度
            , arrow: 'none' //始终显示箭头
            , width: '1080px'
            , height: '150px'
            //,anim: 'updown' //切换动画方式
        });
    });
</script>

<fieldset class="layui-elem-field layui-field-title" >
    <legend><span class="" style="font-size: 14px">
        <a href="/dor/indexdemo">首页<span class="layui-box">&gt;</span></a>
  <span>公告<span class="layui-box">&gt;</span></span>
  <span>公告查看<span class="layui-box">&gt;</span></span>
</span>
    </legend>
</fieldset>
<div class="t">
<div class="" id="layerDemo" style="margin-bottom: 0;">
   <table class="layui-table" lay-skin="line" lay-filter="demo"><tbody class="tips"></tbody>

    </table>
</div>
</div>





<script>
    $(function () {
        $.get('/dor/text', function (data) {
          /*  console.log(data)*/
            var htmls = []
            data.forEach(function (item, index) {
                var demo = '<tr>' +
                    '<td align="left" ><a href="#" class="check-button" data-method="notice" style="margin-left: 20px;" data-index="' + index + '">'
                    + item.title +
                    '</a></td><td>'
                    + item.time +
                    '</td>' +
                    '<td><a class="layui-btn layui-btn layui-btn-mini" onclick="del(this, ' + item.id +  ')">' + '删除' + '</a></td></tr>'

                htmls.push(demo)


            })
            $('.tips').html(htmls.join(''))
            layui.use('layer', function () { //独立版的layer无需执行这一句
                var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句

                //触发事件
                var active = {
                    notice: function (othis) {
                        var index = othis.data('index')
                        var contnet = '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' + data[index].context + '</div>'
                        //示范一个公告层
                        layer.open({
                            type: 1
                            , title: false //不显示标题栏
                            , closeBtn: false
                            , area: '600px;'
                            , shade: 0.8
                            , id: 'LAY_layuipro' //设定一个id，防止重复弹出
                            , btn: ['我知道了']
                            , btnAlign: 'c'
                            , moveType: 1 //拖拽模式，0或者1
                            , content: contnet
                        });
                    }
                };
                $('#layerDemo .check-button').on('click', function () {
                    var othis = $(this), method = othis.data('method');
                    active[method] ? active[method].call(this, othis) : '';
                });

            })
            

/*            layui.use('table', function(){
                var table = layui.table;
                //监听表格复选框选择
//                table.on('checkbox(demo)', function(obj){
//                });

                //监听工具条
                table.on('tool(demo)', function (data) {

                    console(data);
                    console(data.id);
                    if (obj.event === 'del') {
                        layer.confirm('确认删除该老师信息', function (index) {
                            $.ajax({
                                type: "DELETE",
                                url: "/" + obj.data.tea_id,
                                data: "{}",
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (data) { // Play with response returned in JSON format
                                    return true;
                                },
                                error: function (msg) {
                                    return false;
                                }
                            });
                            obj.del();
                            layer.close(index);
                            // console.log('年后');

                        });
                    }

                });

            })*/
        })
    })

</script>

</body>
</html>